<?php
#### BUILD NAVIGATION ##########################################################
function build_navigation() {
	$base =& Base::getInstance();

	// Make the model ready for use
	$base->model = $base->load->model('navigation');
	$base->pages = $base->load->model('pages');

	$items = $base->model->getCachedItemsByPosition();

	$separater = ($base->common['navigation_separator_icon'] ? $base->icon['separator'] : $base->common['navigation_separator_text']);

	$nav = NULL;
	if ($items) foreach ($items as $item) {
		if (!$item['disabled'] && allowed($item['visible_to'])) {
			if ($item['page_id']) $sef = $base->pages->getPageByID($item['page_id'], 'sef_title');
			$url = ($item['page_id'] ? 'pages/'.$sef['sef_title'] : $item['url']);
			$nav .= '<li><a href="'.$url.'">'.$item['name'].'</a>';
			$nav .= ' '.($items[(count($items) -1)]['name'] == $item['name'] ? NULL : $separater).'</li>';
		}
	}

	return $nav;
}
?>